<?php
/*
 * @package
 * @author     wanglei@wyzc.com
 * @version    $Id$
 */

class SomeIterator implements SeekableIterator {

	private $data = array();
	private $index = 0;

	public function __construct($data) {
		$this->data = $data;
	}

	public function next() {
		$this->index++;
	}

	public function current() {
		return $this->data[$this->index];
	}

	public function valid() {
		return $this->index < count($this->data);
	}

	public function rewind() {
		$this->index = 0;
	}

	public function key() {
		return $this->index;
	}

	public function seek($index) {
		if ($index >= count($this->data)) {
			return 'error';
		}
		$this->index = $index;
	}

}